<%--
    Страница для импорта заказа их Excel
--%>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%@taglib prefix="a4j" uri="http://richfaces.org/a4j" %>
<%@taglib prefix="rich" uri="http://richfaces.org/rich" %>
<%@taglib prefix="t" uri="http://myfaces.apache.org/tomahawk" %>

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <meta HTTP-EQUIV="Cache-Control" CONTENT="must-revalidate">
    <meta HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
    <meta HTTP-EQUIV="Cache-Control" CONTENT="no-store">
    <title>Goodwill - Загрузка заказа из Excel</title>
    <link rel="stylesheet" href="resources/css/main.css"/>
    <link rel="stylesheet" href="resources/css/stylesheet.css"/>
    <link rel="stylesheet" href="resources/css/simple_tables.css"/>
    <style type="text/css">
        .pane {
            margin-top: 20px;
            padding: 10px;
        }

        .load_btn
        {
            font-size: 140%;
            margin-top: 20px;
            margin-bottom: 20px;
            
        }
    </style>
</head>
<body>
<f:view>

    <jsp:include page="menu.jsp"/>
    <jsp:include page="status.jsp"/>

    <a4j:form prependId="false" id="jsForm">
        <a4j:jsFunction name="gotoOrder" action="#{SessionBean.getOrderItems}" ajaxSingle="true" oncomplete="document.location='order';">
            <a4j:actionparam name="order_id" assignTo="#{SessionBean.selectedOrderId}"/>
            <a4j:actionparam name="client_id" assignTo="#{SessionBean.selectedClientId}"/>
        </a4j:jsFunction>
    </a4j:form>

    <h:panelGroup layout="block" styleClass="pane">
        <h:form enctype="multipart/form-data">
            <h:panelGrid cellpadding="0" cellspacing="0" columns="2" styleClass="tbl2">
                <h:outputText value="Выберите клиента" styleClass="b"/>
                <h:selectOneMenu value="#{ImportOrderBean.clientId}">
                    <f:selectItems value="#{ImportOrderBean.goodClients}"/>
                </h:selectOneMenu>

                <h:outputText value="Выберите файл" styleClass="b"/>
                <t:inputFileUpload id="file"
                                   value="#{ImportOrderBean.uploadedFile}"
                                   storage="file"/>

                <h:outputText value="Удалять отсутствующие на складе позиции"/>
                <h:selectBooleanCheckbox value="#{ImportOrderBean.removeAbsentPositions}"/>
            </h:panelGrid>

            <h:commandButton value="Загрузка" action="#{ImportOrderBean.upload}" styleClass="load_btn"/><br>
            <jsp:include page="messages.jsp"/>

            <h:panelGroup rendered="#{ImportOrderBean.loadedOrderId != -1}" styleClass="" layout="block" style="padding:4px;border:1px solid black;background:whitesmoke">
                <h:outputLink value="#" onclick="gotoOrder(#{ImportOrderBean.loadedOrderId}, #{ImportOrderBean.loadedOrderClientId});">
                    <h:outputText value="Перейти к заказу"/>
                </h:outputLink>                
            </h:panelGroup>

        </h:form>
    </h:panelGroup>

    <jsp:include page="modalmessages.jsp"/>

    <h:panelGroup layout="block" styleClass="" rendered="#{not empty ImportOrderBean.restsProblems}">
        <h:dataTable cellpadding="0" cellspacing="0" value="#{ImportOrderBean.restsProblems}" var="restProblem" styleClass="tbl1">
            <f:facet name="header">
                <h:outputText value="Нехватка остатков"/>
            </f:facet>
            <h:column>
                <f:facet name="header">
                    <h:outputText value="Код"/>
                </f:facet>
                <h:outputText value="#{restProblem.code}"/>
            </h:column>
            <h:column>
                <f:facet name="header">
                    <h:outputText value="Затребовано"/>
                </f:facet>
                <h:outputText value="#{restProblem.requestedCount}"/>
            </h:column>
            <h:column>
                <f:facet name="header">
                    <h:outputText value="Доступно"/>
                </f:facet>
                <h:outputText value="#{restProblem.count}"/>
            </h:column>
        </h:dataTable>
    </h:panelGroup>
</f:view>
</body>
</html>